/*
 * @Author: Jie
 * @LastEditors: Jie
 * @Date: 2021-05-10 08:51:34
 * @LastEditTime: 2021-06-02 09:05:42
 * @Description:
 * @Email: 18521721605@163.com
 */
import Vue from "vue";
import VueRouter from "vue-router";
import { Notification } from 'element-ui';
Vue.use(VueRouter);

const routes = [
  {
    // home页面
    path: "/",
    name: "Home",
    meta: { title: "标题" },
    component: () => import("../views/Home.vue"), //组件为home
  }, {
    // 404页面
    path: "*",
    name: "404",
    meta: { title: "404" },
    component: () => import("../views/404.vue"),
  }, {
    // 论文审核页面
    path: "/audit",
    name: "Audit",
    component: () => import("../views/Audit.vue"),
  }, {
    // 登录页面
    path: "/login",
    name: "Login",
    component: () => import("../views/Login.vue"),
  }, {
    // 论文管理页面
    path: "/manage",
    name: "Manage",
    component: () => import("../views/Manage.vue"),
  }, {
    // 分类管理页面
    path: "/sort",
    name: "Sort",
    component: () => import("../views/Sort.vue"),
  }, {
    // 公告管理页面
    path: "/ac_Audit",
    name: "ac_Audit",
    component: () => import("../views/ac_Audit.vue"),
  }, {
    // 用户管理页面
    path: "/user_tobe",
    name: "user_tobe",
    component: () => import("../views/user_tobe.vue"),
  }, {
    // 用户管理页面
    path: "/users",
    name: "users",
    component: () => import("../views/users.vue"),
  }
];

const router = new VueRouter({
  routes,
});

//路由前置守卫
//即将进入页面之前调用
// router.beforeEach((to, from, next) => {
//   const need = ['/user'];
//   const token = localStorage.getItem('token_z')
//   let isneed = false;
//   need.forEach((v) => {
//     if (to.path == v) {
//       isneed = true
//     }
//   })

//   if (isneed) { //判断即将进入的页面是否需要登录
//     if (token) {  //如果是那么判断当前是否已经登录
//       next()
//     } else {   // 如果登录了那么直接放行  如果没登录跳转到login页面
//       next('/login')
//     }
//   } else { // 如果不需要登录直接放行
//     next()
//   }
// });

//回调函数

export default router;
